<?php
namespace app\index\controller;
use app\index\model\tableA;
use app\index\model\platformTable;
use app\index\model\productTable;
class Returntable extends Common
{
	public function tablea(){
		return view();
	}
	public function tableaData(){
		$page = request()->param('page');
		$limit = request()->param('limit');
		$start = ($page-1)*$limit;
		$ddh = request()->param('value');
		if($ddh == ''){
			$userinfo = tableA::limit($start,$limit)->order('create_time','desc')->select();
			$count = count(tableA::select());
		}else{
			$userinfo = tableA::withSearch(['order_number'],['order_number'=>$ddh])->limit($start,$limit)->order('create_time','desc')->select();
			$count = count(tableA::withSearch(['order_number'],['order_number'=>$ddh])->select());
		}
		
		$msg = [
			'code'=>0,
			'msg'=>'查询成功',
			'data'=>$userinfo,
			'count'=>$count
		];
		echo json_encode($msg);die;
	}
	
	public function add(){
		$platform = platformTable::where('status', 1)->order('create_time','desc')->select();
		$this->assign('platform',$platform);
		$product = productTable::where('status', 1)->order('create_time','desc')->select();
		$this->assign('product',$product);
		return view();
	}
	public function adddata(){
		$data = request()->param();
		/* halt($data); */
		return (new tableA())->adddata($data);
	}
	public function edit(){
		$id = request()->param('id');
		/* halt($id); */
		$res = tableA::where('id',$id)->find();
		/* $data=array($res); */
		$this->assign('res',$res);
		
		$platform = platformTable::where('status', 1)->order('create_time','desc')->select();
		$this->assign('platform',$platform);
		$product = productTable::where('status', 1)->order('create_time','desc')->select();
		$this->assign('product',$product);
		
		return view();
	}
	public function editdata(){
		$data = request()->param();
		/* halt($data); */
		return (new tableA())->editdata($data);
	}
	public function del(){
		$id = request()->param('id');
		return (new tableA())->del($id);
	}
}